# Contributor: Damian Kurek <starfire24680@gmail.com>
# Maintainer: Damian Kurek <starfire24680@gmail.com>
pkgname=kodi-game-libretro-beetle-supergrafx
pkgver=1.23.0.15
_realname=Matrix
pkgrel=1
pkgdesc="Beetle-Supergrafx for Kodi"
options="!check" # no test suite
url="https://github.com/kodi-game/game.libretro.beetle-supergrafx"
arch="x86 x86_64 aarch64 armv7" # kodi
license="GPL-2.0-only"
makedepends="cmake kodi-dev"
depends="kodi-game-libretro libretro-beetle-supergrafx"
source="$pkgname-$pkgver-$_realname.tar.gz::https://github.com/kodi-game/game.libretro.beetle-supergrafx/archive/$pkgver-$_realname.tar.gz"
builddir="$srcdir/game.libretro.beetle-supergrafx-$pkgver-$_realname"

build() {
	cmake -B build \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_MODULE_PATH=/usr/lib/cmake/kodi
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --build build --target install
	rm -r "$pkgdir"/usr/share/kodi/addons/game.libretro.beetle-supergrafx/resources/icon.png \
		"$pkgdir"/usr/share/kodi/addons/game.libretro.beetle-supergrafx/resources/screenshot* \
		"$pkgdir"/usr/lib/kodi/addons/game.libretro.beetle-supergrafx/game.libretro.beetle-supergrafx.so
	ln -s /usr/lib/libretro/mednafen_supergrafx_libretro.so \
		"$pkgdir"/usr/lib/kodi/addons/game.libretro.beetle-supergrafx/game.libretro.beetle-supergrafx.so
	sed -i '/<assets>/,/<\/assets>/d' "$pkgdir"/usr/share/kodi/addons/game.libretro.beetle-supergrafx/addon.xml
}

sha512sums="119142dea17078d9275e38552a1719faa4ee2b34a15f2896d42a32cf551b1abb1024f624da0e979cdead0581703c07bd230f33a3669ccef4b85af1ac287ea847  kodi-game-libretro-beetle-supergrafx-1.23.0.15-Matrix.tar.gz"
